﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace CallFlowDesigner
{
    public partial class Information : Form
    {
        private CallFlowDesigner callFlowDesigner;

        public CallFlowDesigner CallFlowDesigner
        {
            get { return callFlowDesigner; }
            set { callFlowDesigner = value; }
        }

        public enum Result
        {
            NotSet,
            Cancel,
            GetInformation
        }

        private Result getInformationFlag = Result.NotSet;
        private int timeSpan = 0;

        public int TimeSpan
        {
            get { return timeSpan; }
        }

		  public List<string> SelectedUris;
       

        public Result GetInformationFlag
        {
            get { return getInformationFlag; }
        }


        public Information()
        {
            InitializeComponent();
        }

        private void Information_Load(object sender, EventArgs e)
        {
            cblProvisionedFiles.Items.Clear();
            foreach (ListViewItem o in callFlowDesigner.lstInboundMapfiles.Items)
            {
                string uri = o.SubItems[1].Text + " (" + o.SubItems[0].Text+")";
                cblProvisionedFiles.Items.Add(uri);
            }
            if (cblProvisionedFiles.Items.Count == 0)
            {
                MessageBox.Show("Please upload an XML file to CallFlow first", "CallFlow", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                getInformationFlag = Information.Result.Cancel;
                this.Close();
            }
            else
            {
					cblProvisionedFiles.Sorted = true;
					cblProvisionedFiles.SelectedIndex = 0;
            } 
        }

        private void btnOk_Click(object sender, EventArgs e)
        {
            timeSpan = (int)nudTimeSpan.Value;
				SelectedUris = new List<string>();
				CheckedListBox.CheckedItemCollection cic = cblProvisionedFiles.CheckedItems;
			   foreach (string s in cic)
				{
					SelectedUris.Add(s.Split(' ')[0]);
				}

			   getInformationFlag = Result.GetInformation;
            this.Close();
        }

        
    }
}
